<template>
  <div class="home">
        <nav-tab :dataList="dataList"/>
    <div class="realContent">
      <div class="cont_section">
        <ul class="pro_tab">
          <li @click="clickJump(100)" data-type="100">
            拟申购
            <i
              v-show="companyNumBool(0)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(0)}}</i>
          </li>
          <li data-type="5">
            已受理
            <i
              v-show="companyNumBool(1)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(1)}}</i>
          </li>
          <li data-type="6">
            已问询
            <i
              v-show="companyNumBool(2)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(2)}}</i>
          </li>
          <li data-type="7">
            已通过
            <i
              v-show="companyNumBool(3)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(3)}}</i>
          </li>
          <li data-type="8">
            提交注册
            <i
              v-show="companyNumBool(4)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(4)}}</i>
          </li>
          <li data-type="9">
            已发行
            <i
              v-show="companyNumBool(5)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(5)}}</i>
          </li>
          <li data-type="10">
            中止/终止
            <i
              v-show="companyNumBool(6)"
              class="company_num"
            >{{vtReportInfoCount | companyNum(6)}}</i>
          </li>
        </ul>
      </div>
      <div class="content-scroll-wrapper">
        <div class="scroll-list-wrap">
          <cube-scroll
            ref="contentScroll"
            :data="list"
            :options="options"
            @pulling-down="onPullingDown"
            @pulling-up="onPullingUp"
          >
            <ul class="company_ul">
              <li :key="index" v-for="(item,index) in list">
                <div class="company_title">
                  <span class="company_name">{{item.sShortName}}</span>
                  <span class="change_time">{{item.sUpdateTime}}</span>
                </div>
                <div class="company_info">状态变更：{{item.sState}}</div>
                <div class="pdf_desc">
                  <i class="pdf_icon"></i>
                  <span class="pdf_title">{{item.sInfoTitle}}</span>
                </div>
              </li>
            </ul>
          </cube-scroll>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getReportInfoSimple,
  getReportInfoHistory
} from "../../api/declarationProgress.js";
import NavTab from "@/components/tab/";
export default {
  components: {NavTab},
  data() {
    return {
        dataList: ["科创日历", "科创估值", "科创掘金"],
      vtReportInfoCount: null,
      list: [],
      options: {
        pullDownRefresh: {
          threshold: 60,
          stop: 44,
          stopTime: 1000,
          txt: "更新成功"
        },
        pullUpLoad: {
          threshold: 60,
          stop: 44,
          stopTime: 1000,
          txt: {
            noMore: "没有更多"
          }
        }
      }
    };
  },
  methods: {
    clickJump(type){
       this.$router.push({
          path: '/declarationProgress/quasiDeclaration',
          query: {
            type
          }
        })
    },
    onPullingDown() {
      this.page == 1;
      this.getReportInfoHistory(this.page);
    },
    onPullingUp() {
      this.page++;
      this.getReportInfoHistory(this.page);
    },
    async getReportInfoSimple() {
      let data = await getReportInfoSimple();
      this.vtReportInfoCount = data.vtReportInfoCount;
    },
    async getReportInfoHistory(page) {
      let data = await getReportInfoHistory(page);
      if (data.vtHisReportInfo.length == 0) {
        this.$refs.contentScroll.forceUpdate();
        return;
      }
      if (this.page == 1) {
        this.list = data.vtHisReportInfo;
      } else {
        this.list = this.list.concat(data.vtHisReportInfo);
      }

      // console.log(data)
    },
    companyNumBool(index) {
      if (!this.vtReportInfoCount || this.vtReportInfoCount[index] === 0) {
        return false;
      }
      return true;
    }
  },
  filters: {
    companyNum(arr, index) {
      if (!arr) {
        return "";
      }
      if (arr[index] === 0) {
        return "";
      }
      return arr[index];
    }
  },
  mounted() {
    this.page = 1;
    this.getReportInfoSimple();
    this.getReportInfoHistory(1);
  }
};
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
.home {
  background: #e3e3e3;
  padding-top: 48px;
  z-index: 0;
  .realContent {
    height: 100%;
    display: flex;
    flex-direction: column;
    .cont_section {
      padding-bottom: 8px;
      .pro_tab {
        background: #fff;
        padding-bottom: 8px;
        li {
          display: inline-block;
          width: 20%;
          padding-top: 62px;
          font-size: 14px;
          text-align: center;
          position: relative;
          .company_num {
            display: block;
            position: absolute;
            top: 12px;
            left: 65%;
            height: 14px;
            min-width: 14px;
            border-radius: 14px;
            box-sizing: border-box;
            background: red;
            color: #fff;
            font-size: 12px;
            text-align: center;
            line-height: 14px;
            padding: 0 3px;
          }
          &:nth-child(1) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(2) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(3) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(4) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(5) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(6) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
          &:nth-child(7) {
            background: url()
              no-repeat center 12px;
            background-size: 42px 42px;
          }
        }
      }
    }

    .content-scroll-wrapper {
      flex: 1;
      position: relative;
      .scroll-list-wrap {
        height: 100%;
        width: 100%;
        transform: rotate(0deg); // fix 子元素超出边框圆角部分不隐藏的问题
        position: absolute;
        top: 0;
        bottom: 0;
        overflow: hidden;
        .company_ul {
          li {
            padding: 14px 15px 6px;
            margin-bottom: 8px;
            background: #fff;
            .company_title {
              display: flex;
              justify-content: space-between;
              align-items: center;
              .company_name {
                font-weight: bold;
                font-size: 16px;
              }
              .change_time {
                font-size: 14px;
                color: rgba(37, 37, 37, 0.6);
              }
            }
            .company_info {
              font-size: 14px;
              color: rgba(37, 37, 37, 0.6);
            }
            .pdf_desc {
              font-size: 14px;
              color: #2191eb;
            }
            .pdf_title {
              display: inline-block;
              margin-left: 2px;
              width: calc(100% - 16px);
              vertical-align: top;
              line-height: 17px;
            }
            .pdf_icon {
              vertical-align: top;
              display: inline-block;
              width: 14px;
              height: 14px;
              background: url()
                no-repeat;
              background-size: 14px 14px;
            }
            div {
              margin-bottom: 6px;
            }
          }
        }
      }
    }
  }
}
</style>
